#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,l,r;
signed main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	if(l==r){
		cout<<r%n<<"\n";
		return 0;
	}
	int m1=l/n,m2=r/n;
	if(r-l>=n-1||m1!=m2){
		cout<<n-1<<"\n";
		return 0;
	}
	else cout<<r%n<<"\n";
	return 0;
}
